package com.itheima.mall.dubbo.api.pms;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mall.dubbo.mapper.pms.PmsBrandMapper;
import com.itheima.mall.dubbo.mapper.pms.PmsProductMapper;
import com.itheima.mall.entity.domain.pms.Brand;
import com.itheima.mall.entity.page.MyPage;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class PmsBrandServiceImpl extends ServiceImpl<PmsBrandMapper, Brand> implements PmsBrandService {
    @Autowired
    private PmsBrandMapper brandMapper;
    @Override
    public MyPage<Brand> getList(String keyword, Integer pageNum, Integer pageSize) {
        Page<Brand> brandPage = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<Brand> lqw = new LambdaQueryWrapper<>();
        lqw.like(keyword != null,Brand::getName,keyword);
        brandMapper.selectPage(brandPage,lqw);
        MyPage<Brand> myPage = MyPage.init(brandPage);
        return myPage;
    }
}
